package gameengine.map.unit;

import enumm.DIRECTION;
import enumm.GROUND;
import enumm.UNITTYPE;

public abstract class Unit {

    private final transient int party;
    private transient int power;
    private transient int fuel;
    private transient boolean canAttack = true;

    private DIRECTION dir;

    static final int TANK_MAXP = 30;
    static final int HELI_MAXP = 25;
    static final int SOLDIER_MAXP = 20;
    static final int HORWITZER_MAXP = 50;

    static final int TANK_MAXD = 10;
    static final int HELI_MAXD = 15;
    static final int SOLDIER_MAXD = 5;
    static final int HORWITZER_MAXD = 7;

    static final int TANK_MAXF = 1;
    static final int HELI_MAXF = 1;
    static final int SOLDIER_MAXF = 1;
    static final int HORWITZER_MAXF = 5;

    static final int TANK_MINF = 0;
    static final int HELI_MINF = 0;
    static final int SOLDIER_MINF = 0;
    static final int HORWITZER_MINF = 3;

    static final int TANK_OFF = 5;
    static final int HELI_OFF = 4;
    static final int SOLDIER_OFF = 3;
    static final int HORWITZER_OFF = 7;

    public Unit(final int unitParty) {
        this.power = getMaxPower();
        this.fuel = getMaxDistance();
        this.party = unitParty;
        if (this.party == 1) {
            this.dir = DIRECTION.E;
        } else {
            this.dir = DIRECTION.W;
        }
    }

    public final DIRECTION getDir() {
        return this.dir;
    }

    public final void setDir(final DIRECTION newDir) {
        this.dir = newDir;
    }

    public final int getParty() {
        return this.party;
    }

    public final int getFuel() {
        return this.fuel;
    }

    public final void hasMoved(final int steps) {
        this.fuel -= steps;
    }

    public final int getOffense() {
        this.canAttack = false;
        this.fuel = 0;

        return getAttack();
    }

    public final int decreasePower(final int pow) {
        this.power -= pow;
        return this.power;
    }

    public final void reset() {
        this.canAttack = true;
        this.fuel = getMaxDistance();
    }

    public final boolean canAttack() {
        return this.canAttack;
    }

    @Override
    public abstract String toString();

    public abstract int getMovePoints(final GROUND underGround);

    public abstract int getAttack();

    public abstract int getMaxPower();

    public abstract int getMaxDistance();

    public abstract int getMaxFireRange();

    public abstract int getMinFireRange();

    public abstract UNITTYPE getUnitType();
}
